﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _005_面对对象
{
    class Dog
    {
        //属性 //封装
         public string name { get; set; }
         private int age;
         private bool sex;

        //在整个生命周期内存里面只有一份
        public static string className;


        //默认系统会生成与类名相同的构造方法，但如果自己有声明构造方法的话，系统便不会生成
        public Dog()
        {
            Console.WriteLine("实例化（构造了）一只小狗");
        }

        //初始化
        public Dog(string name)
        {
            this.name = name;
            Console.WriteLine("小狗的名字叫" + name); 
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="name"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        public Dog(string name,int age,bool sex)
        {
            this.name = name;
            this.age = age;
            this.sex = sex;
        }

        //析构函数
        ~Dog()
        {
            Console.WriteLine("销毁一只小狗："+name);
        }


        public void EatSth(string sth)
        {
            Console.WriteLine(name + "吃了" + sth);
            Bake();
        }

        //封装 吼叫 方法
        private void Bake()
        {
            Console.WriteLine(name+":嗷呜嗷呜嗷呜~");
        }

        //减法
        public static int Del(int x,int y)
        {
            return x - y;
        }

        //值类型 告诉程序这是个引用变量
        //xyz就是形式上的参数 形参
        //非静态方法
        public int Add (ref int x, int y,out int z)
        {
            //x重新赋值
            z = x + y;

            x = x + y;

            y = x + z;

            return x+y;
        }
    }
}
